﻿using System;
using System.Runtime.InteropServices;
using System.Windows;

namespace AdTech.Snap.Interop
{
    [StructLayout(LayoutKind.Sequential, Pack = 0)]
    internal struct RECT
    {
        // Fields
        public int Left;
        public int Top;
        public int Right;
        public int Bottom;

        // Constructor
        public RECT(int left, int top, int right, int bottom)
        {
            this.Left = left;
            this.Top = top;
            this.Right = right;
            this.Bottom = bottom;
        }

        public static implicit operator Rect(RECT rectangle)
        {
            return new Rect(rectangle.Left, rectangle.Top, rectangle.Right - rectangle.Left, rectangle.Bottom - rectangle.Top);
        }

        public static implicit operator RECT(Rect rectangle)
        {
            int left = Convert.ToInt32(rectangle.Left);
            int top = Convert.ToInt32(rectangle.Top);
            int right = Convert.ToInt32(rectangle.Right);
            int bottom = Convert.ToInt32(rectangle.Bottom);
            return new RECT(left, top, right, bottom);
        }
    }
}
